#ifndef FTPUPDATE_H
#define FTPUPDATE_H

#include <QObject>
#include <QFtp>

class QFile;
class ftpProgressBar;
class FtpUpdate : public QObject
{
	Q_OBJECT

public:
	int requestGetFileName();
	QString& getFileName();
	int requestDownloadFile(const QString&);
	static FtpUpdate* instance();
	static void destroy();

private slots:
	void ftpCommandStarted(int);
	void ftpCommandFinished(int, bool);
	void ftpGetFilePath(const QUrlInfo&);
	void ftpDataTransferProgress(qint64, qint64);
	void ftpStatusChanged(int);
	void progressBarClosed();
signals:
	void requestFtpResult(int id);
	void progressBarClosedSignal();

private:
	bool login(const QUrl &url);
	FtpUpdate(QObject *parent = NULL);
	~FtpUpdate();
	void InitialProgressBarTitle(const QString& title);
	void createProgressBar();

	QFtp ftp;
	QString fileName;
	QFile *file;
	ftpProgressBar *progressBar;
	static FtpUpdate* ftpUpdate;
	bool abort;
	float downloadPercent;
	int requestFileNameId;
	int requestDownloadId;
};

#endif // FTPUPDATE_H
